//
//  SJOtherFunctionBar.m
//  WSL
//
//  Created by CJ on 2017/12/6.
//  Copyright © 2017年 sanjuetech. All rights reserved.
//

#import "SJOtherFunctionBar.h"

@interface SJOtherFunctionBar ()

@property (strong, nonatomic) UIView *containView;
@property (strong, nonatomic) UIButton *buttonItem_0;

@end

@implementation SJOtherFunctionBar

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    [self addSubview:self.containView];
    self.containView.sd_layout
    .centerYEqualToView(self)
    .centerXEqualToView(self)
    .heightIs(SJLayoutFrame(50))
    .widthIs(SJLayoutFrame(288.5));
    
    [self.containView addSubview:self.buttonItem_0];
    self.buttonItem_0.sd_layout.heightIs(SJLayoutFrame(50));
    
    NSMutableArray *temp = [NSMutableArray new];
    [temp addObject:self.buttonItem_0];
    
    [self.containView setupAutoMarginFlowItems:[temp copy] withPerRowItemsCount:temp.count itemWidth:SJLayoutFrame(47) verticalMargin:0 verticalEdgeInset:0 horizontalEdgeInset:0];

}


#pragma mark -- getter

- (UIView *)containView{
    
    if (!_containView) {
        
        _containView = [UIView new];
    }
    return _containView;
}

- (void)selectedItem:(UIButton *)button {
    
    NSInteger index = button.tag;
    
    if ([self.delegate respondsToSelector:@selector(otherFunctionBar:didSelectItemAtIndex:)]) {
        
        [(id<SJOtherFunctionBarDelegate>)self.delegate otherFunctionBar:self didSelectItemAtIndex:index];
    }
}

- (UIButton *)buttonItem_0{
    
    if (!_buttonItem_0) {
        
        _buttonItem_0 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonItem_0 setImage:[UIImage imageNamed:@"detail_btn_copy"] forState:UIControlStateNormal];
        [_buttonItem_0 addTarget:self action:@selector(selectedItem:) forControlEvents:UIControlEventTouchUpInside];
        _buttonItem_0.tag = 0;
        
    }
    return _buttonItem_0;
}


@end

